When multiple threads need to uncompress an object, there was
a race condition where thread A could get EEXIST, unlink,
then thread B calls linkat(), then thread A tries to link() but
fails.
We can just loop in this case.
gboolean ret_was_supported = FALSE;
ot_lobj GFile *dir = NULL;
+ again:
if (dirfd != -1 &&
linkat (-1, gs_file_get_path_cached (source),
dirfd, gs_file_get_basename_cached (destination), 0) != -1)
* So we can't make this atomic.
*/
(void) unlink (gs_file_get_path_cached (destination));
- if (link (gs_file_get_path_cached (source), gs_file_get_path_cached (destination)) < 0)
- {
- ot_util_set_error_from_errno (error, errno);
- goto out;
- }
+ goto again;
ret_was_supported = TRUE;
}
else